﻿using System;
using System.Collections.Generic;
using System.Text;

/// <summary>
/// 
/// </summary>
public class IgnoreCaseStringComparer : IEqualityComparer<string>
{
	#region Implementation of IEqualityComparer<string>

	/// <summary>
	/// Determines whether the specified objects are equal.
	/// </summary>
	/// <returns>
	/// true if the specified objects are equal; otherwise, false.
	/// </returns>
	/// <param name="x">The first object of type String to compare.</param>
	/// <param name="y">The second object of type String to compare.</param>
	public bool Equals(string x, string y)
	{
		return string.Equals(x, y, StringComparison.CurrentCultureIgnoreCase);
	}

	/// <summary>
	/// Returns a hash code for the specified object.
	/// </summary>
	/// <returns>
	/// A hash code for the specified object.
	/// </returns>
	/// <param name="obj">The <see cref="T:System.Object" /> for which a hash code is to be returned.</param>
	/// <exception cref="T:System.ArgumentNullException">The type of <paramref name="obj" /> is a reference type and <paramref name="obj" /> is null.</exception>
	public int GetHashCode(string obj)
	{
		return obj.ToLower().GetHashCode();
	}

	#endregion
}
